package Chapter8_polymorphism;

/**
 * Date: 2019/2/19
 * Time: 17:16
 * User: Driss.
 *
 * 任何域访问操作都将由编译器解析，因此不是多态的
 */
class Super{
    public int field = 0;
    public int getField(){
        return field;
    }
}

class Sub extends Super{
    public int field = 1;
    public int getField(){
        return field;
    }
    public int getSuperField(){
        return super.field;
    }
}

public class FieldAccess {
    public static void main(String[] args) {
        Super sup = new Sub();
        System.out.println("sup.field = " + sup.field + ",sup.getField() = " + sup.getField());  // sup.field = 0,sup.getField() = 1

        Sub sub = new Sub();
        System.out.println("sub.field = " + sub.field + ",sub.getField() = " + sub.getField() + ",sub.getSuperField() = " + sub.getSuperField());

    }
}
